package com.sinux.sshUser.entity;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import com.fasterxml.jackson.annotation.JsonIgnore;

/**
 * @author WangGan
 * @version 2017年5月16日 下午5:13:47 
 * 资源类
 */

@Entity
@Table(name = "resources")
@DynamicInsert(true)
@DynamicUpdate(true)
public class Resources {
	private String reid;
	private String rename;
	@JsonIgnore
	private Set<Role> roles=new HashSet<Role>();
	
	@Id
	@Column(name = "re_id", unique = true,nullable = false, length = 64)
	public String getReid() {
		return reid;
	}
	public void setReid(String reid) {
		this.reid = reid;
	}
	@Column(name = "re_name", nullable = false, length = 64)
	public String getRename() {
		return rename;
	}
	public void setRename(String rename) {
		this.rename = rename;
	}
	
	@ManyToMany(fetch=FetchType.EAGER)
	@JoinTable(name="re_role_resources",joinColumns={
			@JoinColumn(name="re_id",nullable=false,updatable=false)},inverseJoinColumns={
					@JoinColumn(name="ro_id",nullable=false,updatable=false)})
	public Set<Role> getRoles() {
		return roles;
	}
	public void setRoles(Set<Role> roles) {
		this.roles = roles;
	}
	
	
	
}
